from flask import Flask
from app.extensions import init_extensions
from app.config import Config
import json
from datetime import date, datetime

class CustomJSONEncoder(json.JSONEncoder):
    def default(self, obj):
        if isinstance(obj, (datetime, date)):
            return obj.strftime('%Y-%m-%d %H:%M:%S')  # 或者 '%Y-%m-%d'
        return super().default(obj)

app = Flask(__name__)
app.json_encoder=CustomJSONEncoder
app.config.from_object(Config)

init_extensions(app)

@app.route('/')
def home():
    return 'Flask server is running'

if __name__ == '__main__':
    app.run(debug=True, port=5002)